home *** CD-ROM | disk | FTP | other *** search
/ Merciful 2 / Merciful - Disc 2.iso / software / i / imagefxv2.1a.lha / ImageFX / MAGIC / include / magic / magic.h < prev   
C/C++ Source or Header  |  1996-02-12  |  6KB  |  216 lines

  1. /*
  2.  * MAGIC - structures and definitions.
  3.  *
  4.  * Developed by Thomas Krehbiel
  5.  * Nova Design, Inc.
  6.  *
  7.  * December, 1992
  8.  *
  9.  * V38 - January 1994
  10.  *
  11.  */
  12.  
  13. #ifndef MAGIC_MAGIC_H
  14.  
  15.  
  16. #ifndef EXEC_TYPES_H
  17. #include <exec/types.h>
  18. #endif
  19.  
  20. #ifndef EXEC_NODES_H
  21. #include <exec/nodes.h>
  22. #endif
  23.  
  24. #ifndef EXEC_LISTS_H
  25. #include <exec/lists.h>
  26. #endif
  27.  
  28. #ifndef EXEC_LIBRARIES_H
  29. #include <exec/libraries.h>
  30. #endif
  31.  
  32. #ifndef EXEC_SEMAPHORES_H
  33. #include <exec/semaphores.h>
  34. #endif
  35.  
  36. #ifndef UTILITY_TAGITEM_H
  37. #include <utility/tagitem.h>
  38. #endif
  39.  
  40.  
  41. #define MAGIC_NAME         "magic.library"
  42.  
  43.  
  44. /*
  45.  * Library base
  46.  */
  47. struct MagicBase {
  48.    struct Library          LibNode;
  49.    struct Task            *Server;           /* Server task */
  50.    struct SignalSemaphore  Lock;             /* Lock on PI list */
  51.    struct List             MagicImageList;   /* List of public images */
  52.    struct MagicImage      *DefaultImage;     /* "Active" image */
  53.    LONG                    Counter;          /* Name counter */
  54. };
  55.  
  56.  
  57. /*
  58.  * MAGIC image definition
  59.  */
  60. struct MagicImage {
  61.  
  62.    struct Node             Node;
  63.  
  64.    char                    Name[128];     /* Image name for reference */
  65.  
  66.    ULONG                   Flags;         /* Various flags - see below */
  67.    LONG                    Width;         /* Pixel width */
  68.    LONG                    Height;        /* Pixel height */
  69.    LONG                    Depth;         /* 8-bit planes (generally
  70.                                              1 for greyscale and 3
  71.                                              for color) */
  72.  
  73.    WORD                    AspectX,       /* Horizontal pixel aspect */
  74.                            AspectY;       /* Vertical pixel aspect */
  75.  
  76.    WORD                    DPIX,          /* Horizontal dpi */
  77.                            DPIY;          /* Vertical dpi */
  78.  
  79.    char                   *OwnerName;     /* Name of image's owner */
  80.  
  81.    LONG                    Reserved[7];
  82.  
  83.    UBYTE                  *Red,           /* Direct pointers to RGB planes */
  84.                           *Green,         /* and alpha channel.  If these are */
  85.                           *Blue,          /* NULL, a translation function */
  86.                           *Alpha;         /* must be used instead */
  87.  
  88.    APTR                    ImageData;     /* Image data handle - only
  89.                                              the owner of an image
  90.                                              can mess with this. */
  91.  
  92.    /*
  93.     * The following fields are PRIVATE!  Do not touch.
  94.     */
  95.  
  96.    struct SignalSemaphore  Lock;          /* Semaphore for obtaining
  97.                                              an exclusive write-lock on
  98.                                              the image.  To prevent two
  99.                                              tasks from writing to the
  100.                                              image at the same time. */
  101.    struct Task            *Owner;         /* Task owning this image. */
  102.    struct MsgPort         *OwnerPort;     /* Owner's message port. */
  103.    struct List             OpenList;      /* List of tasks that currently
  104.                                              have access to this
  105.                                              image. */
  106.    LONG                    OpenCount;     /* Number of tasks (besides
  107.                                              the owner) that currently
  108.                                              have this image open. */
  109.  
  110.    int                   (*GetData)(struct MagicImage *, LONG, LONG, Tag *);
  111.    int                   (*PutData)(struct MagicImage *, LONG, LONG, Tag *);
  112.  
  113. };
  114.  
  115. /*
  116.  * MagicHandle - returned by OpenMagicImage()
  117.  */
  118. struct MagicHandle {
  119.    struct Node             Node;
  120.    UWORD                   Flags;         /* reserved */
  121.    struct MagicImage      *Object;        /* Image that is opened */
  122.    struct MsgPort         *Port;          /* Port to send messages
  123.                                              about this image. */
  124. };
  125.  
  126.  
  127. /* Tags passed to AllocMagicImage(): */
  128. enum AMI_Tags {
  129.    AMI_Width = (int)TAG_USER,
  130.    AMI_Height,
  131.    AMI_Depth,
  132.    AMI_Name,
  133.    AMI_ImageData,
  134.    AMI_GetDataCode,
  135.    AMI_PutDataCode,
  136.    AMI_MsgPort,
  137.    AMI_Red,
  138.    AMI_Green,
  139.    AMI_Blue,
  140.    AMI_Alpha,
  141.    AMI_AspectX,
  142.    AMI_AspectY,
  143.    AMI_DPIX,
  144.    AMI_DPIY,
  145.    AMI_OwnerName
  146. };
  147. #define AMI_Grey  AMI_Red
  148.  
  149. /* Tags passed to OpenMagicImage(): */
  150. enum OMI_Tags {
  151.    OMI_MsgPort = (int)TAG_USER,    /* opener's should use this */
  152.    OMI_OwnerPort,             /* owner's should use this instead */
  153. };
  154.  
  155. /* Tags passed to GetMagicImageData() and PutMagicImageData(): */
  156. enum GMI_Tags {
  157.    GMI_Red = (int)TAG_USER,  /* red bytes */
  158.    GMI_Green,           /* green bytes */
  159.    GMI_Blue,            /* blue bytes */
  160.    GMI_RGB,             /* RGB bytes (requires 3 times storage!) */
  161.    GMI_ARGB,            /* ARGB bytes (requires 4 times storage!) */
  162.    GMI_Alpha,           /* alpha channel bytes */
  163.    GMI_Mask,            /* (reserved) */
  164.    GMI_RGBA,            /* RGBA bytes (requires 4 times storage!) (V38) */
  165. };
  166. #define GMI_Grey  GMI_Red
  167.  
  168. /* Lock types passed to [Attempt]LockMagicImage(): */
  169. #define LMI_Read           1
  170. #define LMI_Write          2
  171.  
  172. /* Tags passed to PickMagicImageA(): */
  173. enum PMI_Tags {
  174.    PMI_IncludeName = (int)TAG_USER,
  175.    PMI_ExcludeName,
  176.    PMI_IncludeOwner,
  177.    PMI_ExcludeOwner,
  178.    PMI_MinWidth,
  179.    PMI_MinHeight,
  180.    PMI_MinDepth,
  181.    PMI_MaxWidth,
  182.    PMI_MaxHeight,
  183.    PMI_MaxDepth,
  184.    PMI_ShowSize,
  185.    PMI_ShowOwner,
  186.    PMI_All,
  187. };
  188.  
  189. /*
  190.  * Messages sent to OwnerPort, and/or to each opener.
  191.  */
  192. struct MagicMessage {
  193.    struct Message          Msg;           /* Exec message */
  194.    struct MagicImage      *Object;        /* Object of this message */
  195.    LONG                    Action;        /* What to do */
  196.    LONG                    Args[8];       /* Up to 8 parameters */
  197.    LONG                    Result;        /* Result code */
  198.    struct Task            *Server;        /* Server task - do not touch */
  199. };
  200.  
  201. /* Message Actions */
  202. enum Act_Tags {
  203.    MMSG_KILLSERVER = 0,                   /* Server Private */
  204.    MMSG_REDRAW,                           /* Redraw image */
  205.    MMSG_TOFRONT,                          /* Bring interface to front */
  206.    MMSG_UPDATE,                           /* Update size */
  207.    MMSG_SAVEUNDO,                         /* Save a copy of buffer */
  208.    MMSG_RESTOREUNDO,                      /* Restore undo buffer */
  209.    MMSG_CLOSE,                            /* Closing an image */
  210. };
  211.  
  212.  
  213.  
  214. #define MAGIC_MAGIC_H
  215. #endif
  216.